package com.definity.toolkit.web.taglib;

import java.util.Date;

import javax.servlet.jsp.JspException;

import com.definity.toolkit.util.DateUtils;

public class DiffTimeTag extends BaseTag {
	
	private static final long serialVersionUID = -3426306344186292087L;

	private Date date;
	private Date finalDate;

	public DiffTimeTag() {
		setFinalDate(new Date());
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
	
	public void setFinalDate(Date finalDate) {
		this.finalDate = finalDate;
	}
	
	@Override
	public int doEndTag() throws JspException {
		if (date == null)
			return EVAL_PAGE;
		
		write(DateUtils.getPeriod(date, finalDate));

		return EVAL_PAGE;
	}

}
		
